package com.academico.web.servlet.matricula;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.academico.dao.MatriculaDAO;
import com.academico.model.Matricula;
import com.academico.util.Util;
import com.academico.web.servlet.BaseServlet;

public class ShowToEditMatriculaServlet extends BaseServlet {

	private static final long serialVersionUID = -4212064072022915579L;

	@Override
	public void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		List<String> errors = new ArrayList<String>();
		Integer raAluno = Util.convertStringToInteger(request.getParameter("raAluno"));
		Integer codigoCurso = Util.convertStringToInteger(request.getParameter("codigoCurso"));
		
		if(Util.isNull(raAluno) || Util.isNull(codigoCurso)){
			errors.add("Parametros invalidos");
		} else {
			MatriculaDAO matriculaDAO = new MatriculaDAO();
			Matricula matricula = matriculaDAO.find(raAluno, codigoCurso);
			request.setAttribute("matricula", matricula);
		}
		
		forward("editMatricula.jsp", request, response);
		
	}

}
